package test;
import java.util.Arrays;
class Books implements Comparable<Books> {
    private String title;
    private double price;
    public Books(String title,double price){
        this.title = title;
        this.price = price;
    }
    public String toString(){
        return "【书名】" + this.title + "【价格】" + this.price + "\n";
    }
    @Override
    public int compareTo(Books o) {
        if (this.price > o.price) {
            return 1;
        }else if (this.price < o.price) {
            return -1;
        }else {
            return 0;
        }
    }
}
public class YootkDemo11 {
    public static void main(String[] args) throws Exception{
        Books[] books = new Books[] {
                new Books("《Java Web开发》", 68.8),
                new Books("《C语言程序设计》", 48.8),
                new Books("《C#语言程序设计》", 58.8) };
        Arrays.sort(books);
        System.out.println(Arrays.toString(books));
    }
}
